#include "algo.h"

static bool
hasNoEdge(Graph *graph) {
	for (int i = 0 ; i < graph->getNbVertex(); i++) {
		if (graph->numEdge(i) > 0)return false;
	}
	return true;
}


//renvoie la liste des sommets couvrants
vector<int>
ApprocheVoisinage(const Graph *graph) {
	vector<int> coverVertexes;
	Graph *copy = graph->copy();
	int current_vertex = 0;
	int adj_vertex = 0;
	while(!hasNoEdge(copy)) {
		if(copy->numEdge(current_vertex)!=0)
		{
		  int adj_vertex = copy->getNeighbours(current_vertex)[0];
		  coverVertexes.push_back(current_vertex);
		  coverVertexes.push_back(adj_vertex);
		  copy->delVertex(current_vertex);
		  copy->delVertex(adj_vertex);
		}
		else
			current_vertex++;

	}
	return coverVertexes;
}



